home *** CD-ROM | disk | FTP | other *** search
/ Directorty Opus 5 - Magellan 2 / Opus 5 - Magellan 2.iso / Extras / D51_NARexx / PlayMod_MP.dopus5 < prev    next >
Text File  |  1995-12-25  |  6KB  |  151 lines

  1. /* Mod-Player interface for Directory Opus 5.
  2.  By Leo 'Nudel' Davidson for Gods'Gift Utilities
  3.  email: leo.davidson@keble.oxford.ac.uk  www: http://info.ox.ac.uk/~kebl0364/
  4.  
  5. $VER: PlayMod_MP.dopus5 1.3 (25.12.95)
  6.  
  7.    This version is for use with MultiPlayer by Bryan Ford, but should be
  8.    easy to adapt to any other player with an ARexx port, such as
  9.    Eagle/DeliTracker, DMP, etc.
  10.    (In fact, a DeliTracker version should come with this script!).
  11.  
  12.    If you include the path of a module on the command line, using {f}, only
  13.    this mod will be played. If you omit the {f}, the program will play each
  14.    selected file in the first SOURCE lister, giving you a requester to go to
  15.    the next file or stop playing.
  16.  
  17.    If the player's ARexx port is not found, the program will be run for
  18.    you (you should edit the path below). This means the script may fail if
  19.    you disable the player's ARexx port, or give an incorrect command line
  20.    to it.
  21.    If the player's ARexx port takes over a minute to appear, an error
  22.    requester will appear on the DOpus screen and the script will quit.
  23.    REMEMBER to add the "RUN" command to the player command line if it does
  24.    not automatically detach from the shell (MultiPlayer does)!
  25.  
  26.    If the player was running to start with, or the user selects
  27.    "Leave Playing", the module will continue playing when the script finishes.
  28.    Otherwise, the player will be quit.
  29.  
  30. Call as:
  31. ------------------------------------------------------------------------------
  32. ARexx    DOpus5:ARexx/PlayMod_MP.dopus5 {Qp} [{f}]
  33. ------------------------------------------------------------------------------
  34. Turn off all switches.
  35. "[]" means this part is optional.
  36.  
  37.    v1.00 -> v1.01 - Now uses stem variables to get the lister handle.
  38.                     Some minor tidying up.
  39.                     Now checks to make sure the DOPUS.x port exists.
  40.     v1.01 -> v1.2 - Now uses Show() instead of ShowList(). (Thanks Stoebi)
  41.                     Style Guide compliant version numbering and $VER string.
  42.      v1.2 -> v1.3 - Changed the way it loads the mod-player into memory
  43.                     as it was causing problems.
  44.                   - Added "NoRequest" to the Multiplayer command-line to
  45.                     stop it openning a file requester for people who haven't
  46.                     saved a module-programme.
  47.                   - I think there were some problems with filenames containing
  48.                     spaces but they're no longer here as far as I can tell.
  49.                     (Maybe I fixed them and forgot that I'd done it...)
  50.  
  51. */
  52. /*- Path to MultiPlayer command --------------------------------------------*/
  53. MultiPlayer = "DH0:Tools/Music/MultiPlayer"
  54. /*--------------------------------------------------------------------------*/
  55. options results
  56. options failat 99
  57. signal on syntax;signal on ioerr        /* Error trapping */
  58. parse arg DOpusPort FilePath
  59. DOpusPort = Strip(DOpusPort,"B",'" ')
  60. FilePath = Strip(FilePath,"B",'" ')
  61.  
  62. If DOpusPort="" THEN Do
  63.     Say "Not correctly called from Directory Opus 5!"
  64.     Say "Load this ARexx script into an editor for more info."
  65.     EXIT
  66.     END
  67. If ~Show("P",DOpusPort) Then Do
  68.     Say DOpusPort "is not a valid port."
  69.     EXIT
  70.     End
  71. Address value DOpusPort
  72.  
  73. Quit_After = "NO"
  74. If ~Show("P","RXTRACKER") Then Do
  75.     Address Command MultiPlayer "NOREQUEST"
  76.     Address Command "WaitForPort RXTRACKER"
  77.     Quit_After = "YES"
  78.     If ~Show("P","RXTRACKER") then do
  79.         dopus request '"Error loading MultiPlayer!'|| '0a'x ||'Check its command-path in the ARexx script itself." OK'
  80.         EXIT
  81.         END
  82.     END
  83.  
  84. /* If file-path was specified on command line, just play that mod, else
  85.    go through all the selected ones. */
  86.  
  87. If FilePath = "" Then Do
  88.     lister query source stem source_handle.
  89.     IF source_handle.count = 0 | source_handle.count = "SOURCE_HANDLE.COUNT" Then Do
  90.         dopus request '"You must have a SOURCE lister!" OK'
  91.         EXIT
  92.         End
  93.     lister set source_handle.0 busy 1
  94.  
  95.     lister query source_handle.0 numselentries    /* Get info about selected */
  96.     Lister_NumSelEnt = RESULT            /* entries & path to them */
  97.     lister query source_handle.0 path
  98.     Lister_Path = Strip(RESULT,"B",'"')
  99.  
  100.     Do i=1 to Lister_NumSelEnt
  101.         lister query source_handle.0 firstsel
  102.         Temp_Name = Strip(RESULT,"B",'"')
  103.         lister select source_handle.0 Temp_Name 0
  104.         Temp_Path = Lister_Path || Temp_Name
  105.         Address RXTRACKER Load Temp_Path;Address RXTRACKER Play
  106.  
  107.         If Lister_NumSelEnt - i > 0 Then Do
  108.             If Quit_After = "YES" Then
  109.                 dopus request '"Playing module ' i ' of ' Lister_NumSelEnt ':' X2C(0A) Temp_Name '" Next|Leave Playing|Stop'
  110.             Else
  111.                 dopus request '"Playing module ' i ' of ' Lister_NumSelEnt ':' X2C(0A) Temp_Name '" Next|Leave Playing'
  112.             IF RC = "0" THEN BreakIt = "YES"
  113.             IF RC = "2" THEN Do
  114.                 BreakIt = "YES"
  115.                 Quit_After = "NO"
  116.                 END
  117.             End
  118.  
  119.         Else Do
  120.             If Quit_After = "YES" Then
  121.                 dopus request '"Playing module ' i ' of ' Lister_NumSelEnt ':' X2C(0A) Temp_Name '" Leave Playing|Stop'
  122.             Else
  123.                 dopus request '"Playing module ' i ' of ' Lister_NumSelEnt ':' X2C(0A) Temp_Name '" Leave Playing'
  124.             IF RC = "1" Then Quit_After = "NO"
  125.             End
  126.  
  127.         IF BreakIt = "YES" THEN BREAK
  128.         END
  129.     End
  130.  
  131. ELSE Do
  132.     Address RXTRACKER Load FilePath;Address RXTRACKER Play
  133.     If Quit_After = "YES" Then
  134.         dopus request '"Playing module:' X2C(0A) FilePath'" Leave Playing|Stop'
  135.     Else
  136.         dopus request '"Playing module:' X2C(0A) FilePath'" Leave Playing'
  137.     IF RC ~= "0" THEN Quit_After = "NO"
  138.     End
  139.  
  140. /*-- Restore the Lister for normal use --------------------------------------*/
  141. syntax:;ioerr:                /* In case of error, jump here */
  142. END_PART_2:
  143. If FilePath = "" Then Do
  144.     lister refresh source_handle.0
  145.     lister set source_handle.0 busy 0
  146.     END
  147. END_PART:
  148. If Quit_After = "YES" Then Address RXTRACKER QUIT
  149.  
  150. EXIT
  151.